@extends('layouts.application')

@section('css')
    <style>
        .error {
            color: red;
        }
    </style>
@endsection
@section('content')
    <div class="admin-content">

        <div class="am-cf am-padding">
            <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">编辑用户</strong> /
                <small>Edit User</small>
            </div>
        </div>

        <div class="am-g">
            <div class="am-u-sm-12 am-u-md-12">
                <div class="am-tab-panel">
                    <form class="am-form" action="{{route('system.user.update',$user->id)}}" method="post">

                        {{ csrf_field() }}
                        {{method_field('PUT')}}
                        @include('layouts.shared._flash')

                        <div class="am-g am-margin-top">
                            <div class="am-u-sm-4 am-u-md-3 am-text-right">
                                用户名
                            </div>
                            <div class="am-u-sm-8 am-u-md-4 am-u-end col-end">
                                <input type="text" class="am-input-sm" name="name" value="{{ old('name') ? old('name') : $user->name }}">
                            </div>
                        </div>

                        <div class="am-g am-margin-top">
                            <div class="am-u-sm-4 am-u-md-3 am-text-right">
                                邮箱
                            </div>
                            <div class="am-u-sm-8 am-u-md-4 am-u-end col-end">
                                <input type="text" class="am-input-sm" name="email" value="{{ old('email') ? old('email') : $user->email}}">
                            </div>
                        </div>

                        <div class="am-g am-margin-top">
                            <div class="am-u-sm-4 am-u-md-3 am-text-right">
                                手机号
                            </div>
                            <div class="am-u-sm-8 am-u-md-4 am-u-end col-end">
                                <input type="text" class="am-input-sm" name="mobile" value="{{$user->mobile}}">
                            </div>
                        </div>
                        <div class="am-g am-margin-top">
                            <div class="am-u-sm-4 am-u-md-3 am-text-right">
                                原始密码
                            </div>
                            <div class="am-u-sm-8 am-u-md-4 am-u-end col-end">
                                <input type="password" class="am-input-sm" name="old_password" placeholder="请输入原密码">
                            </div>
                        </div>

                        <div class="am-g am-margin-top">
                            <div class="am-u-sm-4 am-u-md-3 am-text-right">
                                新密码
                            </div>
                            <div class="am-u-sm-8 am-u-md-4 am-u-end col-end">
                                <input type="password" class="am-input-sm" id="password" name="password"
                                       placeholder="请输入新密码">
                            </div>
                        </div>

                        <div class="am-g am-margin-top">
                            <div class="am-u-sm-4 am-u-md-3 am-text-right">
                                确认密码
                            </div>
                            <div class="am-u-sm-8 am-u-md-4 am-u-end col-end">
                                <input type="password" class="am-input-sm" id="password_confirmation"
                                       placeholder="请确认新密码"
                                       name="password_confirmation">
                            </div>
                        </div>

                        <div class="am-g am-margin-top">
                            <div class="am-u-sm-4 am-u-md-3 am-text-right">
                                选择用户组
                            </div>
                            <div class="am-u-sm-8 am-u-md-4 am-u-end col-end">

                                @foreach($roles as $role)
                                    <label class="am-checkbox-inline">
                                        <input type="checkbox" id="check" class="checked_id"
                                               name="role_id[]" value="{{$role->id}}"
                                               @if(old('role_id'))
                                                   @if(in_array($role->id, old('role_id')))
                                                   checked
                                                   @endif
                                               @elseif($user_roles->contains($role->id))
                                                   checked
                                                @endif
                                        />{{$role->name}}
                                    </label>
                                @endforeach

                            </div>
                        </div>

                        <div class="am-g am-margin-top am-u-lg-push-1">
                            <button type="submit" class="am-btn am-btn-primary">保 存</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
@endsection

@section('js')
    <script src="/vendor/validate/jquery.validate.js"></script>
    <script src="/vendor/validate/additional-methods.js"></script>
    <script src="/vendor/validate/localization/messages_zh.min.js"></script>
    <script src="/vendor/validate/validator.js"></script>
@endsection


